package com.sheep.classroompie.service;

import com.sheep.classroompie.entity.Course;
import com.sheep.classroompie.entity.Student;
import com.sheep.classroompie.repository.CourseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService{
  @Autowired
  CourseRepository courseRepository;
  @Override
  public List<Course> querySelectedCourse(Integer stuId) {
    return courseRepository.querySelectedCourse(stuId);
  }

  @Override
  public Course selectCourseById(String courseId) {
    if(courseId == null){
      System.out.println("未接收到课程码!");
    }
    return courseRepository.selectCourseById(courseId);
  }

  @Override
  public Boolean addCourse(Course course) {
    return courseRepository.addCourse(course);
  }

  @Override
  public List<Course> queryTaughtCourse(Integer teacherId) {
    return courseRepository.queryTaughtCourse(teacherId);
  }

  @Override
  public boolean deleteCourse(String courseId) {
    return courseRepository.deleteCourse(courseId);
  }

  @Override
  public boolean joinCourse(Integer stuId, String courseId) {
    return courseRepository.joinCourse(stuId,courseId);
  }

  @Override
  public void updateCourseMembersCount(String courseId) {
      courseRepository.updateCourseMembersCount(courseId);
  }

  @Override
  public List<String> selectStudentIdByCourseId(String courseId) {
    return courseRepository.selectStudentIdByCourseId(courseId);
  }
}
